package servlet;

import bean.*;


import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(name = "AwardServlet", value = "/manager/AwardServlet")
public class AwardServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        PrintWriter out=response.getWriter();
        String id=request.getParameter("id");
        String name=request.getParameter("name");
        String reward=request.getParameter("award");
        HttpSession session=request.getSession();
        session.setAttribute("ID",id);
        AwardBean awardBean=new AwardBean();
        awardBean.link();
        awardBean.loadAward();
        Award award=new Award(id,name,reward);
        awardBean.insertAward(award);
        response.sendRedirect("notice.jsp");
    }
}